package com.jiyinit.web.core.business.dao;

import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.web.core.business.entity.TabCoreRoleResourceEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author lishaochuan
 * @version 1.0
 * @date 2017/4/21 15:59
 * @since 1.0
 */
@Repository("core.tabCoreRoleResourceDao")
public class TabCoreRoleResourceDao {

    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(TabCoreRoleResourceDao.class);

    private String SQLID = "core.tabCoreRoleResourceDao.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;


    /**
     * 根据角色ID，删除角色资源关系数据
     * @author lishaochuan
     * @create 2017/4/21 16:04
     * @param
     * @return
     */
    public int deleteByRoleId(Integer roleId) {
        Map<String, Object> params = new HashMap<>();
        params.put("roleId", roleId);
        return mybatisDaoContext.delete(SQLID + "deleteByRoleId", params);
    }

    /**
     * 批量添加
     * @author lishaochuan
     * @create 2017/4/21 16:30
     * @param
     * @return
     */
    public int bathSave(List<TabCoreRoleResourceEntity> roleResources){
        return mybatisDaoContext.batchSave(SQLID + "save", roleResources);
    }

}
